import sqlite3

file = open('mates.csv')
conn = sqlite3.connect('test.db')
cur = conn.cursor()

test = cur.execute('''
            select * from sqlite_master
            where type = 'table'
            and name = 'MATES'
            ''')
if len(test.fetchall()) > 0:
    cur.execute('''
        drop table mates
        ''')
cur.execute('''
        CREATE TABLE MATES(
        ID INTEGER RPIMARY KEY,
        NAME CHAR(20) NOT NULL,
        BINGO INT DEFAULT 0)
        ''')

id = 0
for name in file:
    id += 1
    cur.execute('INSERT INTO MATES (ID, NAME) VALUES (%i, "%s")' % (id, name.strip()))
conn.commit()
conn.close()
